package org.genntii.smcommon.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ExpiredExchangeConfiguration {

    public static final String EXPIRED_EXCHANGE = "expired.direct";

    private static final String EXPIRED_QUEUE = "expired.queue";

    @Bean
    public DirectExchange expiredExchange() {
        return new DirectExchange(EXPIRED_EXCHANGE);
    }

    @Bean
    public Queue expiredQueue() {
        return QueueBuilder.durable(EXPIRED_QUEUE).deadLetterExchange(ErrorMessageConfiguration.errorDirectExchange).build();
    }

    @Bean
    public Binding expiredBinding() {
        return BindingBuilder.bind(expiredQueue()).to(expiredExchange()).with(ErrorMessageConfiguration.errorRoutingKey);
    }
}
